import _toast from './toast.vue'

let $vm;
export default {
  install(Vue,options){
    if(!$vm){
      const toastPlunin = Vue.extend(_toast);
      $vm = new toastPlunin({
        el: document.createElement('div'),
        data(){
          return{
            content:'',
            show:false
          }
        }
      })
      console.log($vm)
      document.body.appendChild($vm.$el);
    }
    if (!Vue.$_toast) {
      Vue.$_toast = (content)=>{
        $vm.content = content;
        $vm.show = true;
        setTimeout(()=>{
          $vm.show = false;
        },2000)
      }

    }
    Vue.mixin({
      created () {
        this.$_toast = Vue.$_toast
      }
    })
  },
}
